Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stateful now supports vmap #466

Merged
merged 3 commits into from
Sep 12, 2023
Merged

Stateful now supports vmap #466

merged 3 commits into from
Sep 12, 2023

Conversation

patrick-kidger
Copy link
Owner

@patrick-kidger patrick-kidger commented Aug 31, 2023

This is actually a minor breaking change: the API has changed from eqx.nn.StateIndex(callable_returning_value) to just eqx.nn.StateIndex(value). In practice creating custom stateful layers was an advanced API surface that wasn't really documented before, so I'm tempted to release this as a v0.10.* release, rather than bumping to v0.11.0.

This also updates the recommended way of creating state from eqx.nn.State(model) to eqx.nn.make_with_state(model). This is needed to ensure memory usage behaves correctly. Nonetheless the previous eqx.nn.State(model) approach will do the correct thing (other than consuming some extra memory), for backward compatibility.

This change also introduces substantially updated documentation on stateful layers, which should help usage here a lot.

For information on how things now work, first take a look at this example for the "normal" API, and then this further documentation for more details on creating custom layers, and using stateful layers with vmap.

@patrick-kidger patrick-kidger changed the base branch from main to moved-inference August 31, 2023 17:43
@patrick-kidger patrick-kidger changed the title better stateful Stateful now supports vmap Aug 31, 2023
Base automatically changed from moved-inference to dev September 5, 2023 14:32
This is actually a minor breaking change: the API has changed from
StateIndex(callable_returning_value) to just StateIndex(value).

This change also introduces substantially updated documentation on
stateful layers, which should help a lot.
…that they are compatible with the original model.
@patrick-kidger patrick-kidger marked this pull request as ready for review September 12, 2023 13:35
@patrick-kidger patrick-kidger merged commit 4a991eb into dev Sep 12, 2023
2 checks passed
@patrick-kidger patrick-kidger deleted the better-stateful branch September 12, 2023 13:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant